<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('teachingTransfer')} > ${i18n.getMessage('edit')}">
	<a href="#" onclick="cc('offering/showListTeachingSwitch.sgt?offeringId=${(offering.id)!}')">${i18n.getMessage('list')}</a>
	- <a href="#" onclick="cc('offering/showInfoOffering.sgt?id=${(offering.id)!}')">${i18n.getMessage('offering')}</a>
</@showTitle>

<div id="error" style="display:none"></div>

<form action="offering/editTeachingSwitch.sgt" validator="offering/validateTeachingSwitch.sgt" onsubmit="submitFormValidation(this); return false;" onreset="$('error').hide()">
	<input type="hidden" name="offeringId" value="${offering.id}"/>
	<input type="hidden" name="id" value="${model.id}"/>
	
	<table id="dataTable" align="center" cellspacing="5" cellpadding="0">
		<tr>
			<td class="name"><@required/>${i18n.getMessage('class')}:</td>
			<td><input type="text" value="${(offering.name)!}" disabled style="width:200px"/></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('teacher')}:</td>
			<td>
				<select name="day" style="width:204px">
					<option></option>
					<#list days as day>
						<#assign teacher = (offering.getInstructorOfDay(day, null))!>
						<option value="${day}" <#if day==(model.mainDay)!>selected</#if>>${DateUtil.getDateOfWeekAsString(day)} # ${(teacher.fullName)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('inplaceTeacher')}:</td>
			<td>
				<select name="inplaceTeacherId" style="width:204px">
					<option></option>
					<OPTGROUP LABEL="${i18n.getMessage('mainTeachers')}">
						<#list teachers as teacher>
							<option value="${teacher.id}" <#if teacher==(model.inplaceTeacher)!>selected</#if>>${(teacher.fullName)!}</option>
						</#list>
					</OPTGROUP>
					<#if (others.size() > 0)>
					<OPTGROUP LABEL="${i18n.getMessage('otherTeachers')}">
						<#list others as teacher>	
							<option value="${teacher.id}" <#if teacher==(model.inplaceTeacher)!>selected</#if>>${(teacher.fullName)!}</option>
						</#list>
					</OPTGROUP>
					</#if>
				</select>
				
			</td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('fromDate')}:</td>
			<td><input type="text" name="fromDate" value="${(model.fromDate)!}" style="width:200px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].fromDate, '${i18n.getMessage('format.date')}', this)"/></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('toDate')}:</td>
			<td><input type="text" name="toDate" value="${(model.toDate)!}" style="width:200px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].toDate, '${i18n.getMessage('format.date')}', this)"/> <a style="font-style:italic" href="#" onclick="document.forms[0].toDate.value='${(offering.endDate?date)!}'">Insert end date</a></td>
		</tr>
		<tr>
			<td class="name" style="vertical-align:top">${i18n.getMessage('comment')}:</td>
			<td><textarea name="comment" style="width:300px;height:80px">${(model.comment)!}</textarea></td>
		</tr>
		<tr>
			<td></td>
			<td>
				<input type="submit" value="${i18n.getMessage('edit')}" class="button_style"/> 
				<input type="reset" value="${i18n.getMessage('reset')}" class="button_style"/> 
			</td>
		</tr>
	</table>
</form>

<script>
	$('error').hide();
</script>